package com.zerui.manager.web.enums;

import lombok.Getter;

/**
 * 开关暂时不写新枚举 公用一个
 * @Author lvfengjun
 * @create_time 2023-08-25 14:23
 */

@Getter
public enum DeviceAccessStatusEnum {

    OPEN(0,"autoOpenEnable","开"),

    CLOSE(1,"autoOpenDisable","关"),

    INSERT_PERSON(2, "insertPersons", "添加人员"),

    REMOVE_PERSON(3, "removePersons", "删除人员"),
    ;

    private final Integer code;

    private final String action;

    private final String name;

    DeviceAccessStatusEnum(Integer code, String action, String name) {
        this.code = code;
        this.action = action;
        this.name = name;
    }

    public static String getActionByCode(Integer code){
        DeviceAccessStatusEnum[] values = DeviceAccessStatusEnum.values();
        for (DeviceAccessStatusEnum deviceOperateEnum:values){
            if(deviceOperateEnum.getCode().equals(code)){
                return deviceOperateEnum.getAction();
            }
        }
        return null;
    }

	public static String getNameByAction(String action){
		DeviceAccessStatusEnum[] values = DeviceAccessStatusEnum.values();
		for (DeviceAccessStatusEnum deviceOperateEnum:values){
			if(deviceOperateEnum.getAction().equals(action)){
				return deviceOperateEnum.getName();
			}
		}
		return null;
	}

    public static DeviceAccessStatusEnum getDeviceOperateEnum(Integer code){
        DeviceAccessStatusEnum[] values = DeviceAccessStatusEnum.values();
        for (DeviceAccessStatusEnum deviceOperateEnum:values){
            if(deviceOperateEnum.getCode().equals(code)){
                return deviceOperateEnum;
            }
        }
        return null;
    }

}
